package com.xushi.service.impl;

import com.xushi.dao.ActivityGradeRepository;
import com.xushi.model.ActivityGrade;
import com.xushi.service.ActivityGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;
import java.util.List;

/**
 * Created by 14553 on 2018/5/5.
 */
@Service("activityGradeService")
@Transactional
public class ActivityGradeServiceImpl implements ActivityGradeService {

    @Autowired
    private ActivityGradeRepository activityGradeDao;

    public ActivityGrade saveGrade(int grade, String activityId, String username, Timestamp time) {
        ActivityGrade activityGrade = new ActivityGrade();
        activityGrade.setActivityId(activityId);
        activityGrade.setGrade(grade);
        activityGrade.setUsername(username);
        activityGrade.setTime(time);
        return activityGradeDao.save(activityGrade);
    }

    public List<ActivityGrade> getGrade(String activityId, String username) {
        return activityGradeDao.findActivityGradeByActivityIdAndUsername(activityId, username);
    }

    public List<ActivityGrade> getGradeList(String activityId) {
        return activityGradeDao.findActivityGradeByActivityId(activityId);
    }
}
